package Demo1;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-07-08
 * Time: 9:53
 */
/*class Login {
    private String userName = "123";
    private String passWord = "321";

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    public void loginInfo(String userName,String passWord) {
        if(!this.userName.equals(userName)) {
            System.out.println("用户名错误");
            return;
        }
        if(!this.passWord.equals(passWord)) {
            System.out.println("密码错误");
            return;
        }
        System.out.println("登录成功");
    }
}
public class Test {
    public static void main(String[] args) {
        Login login = new Login();
        Scanner scanner = new Scanner(System.in);
       login.loginInfo(scanner.nextLine(),scanner.nextLine());
    }
}*/
class Login {
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    public void loginInfo(String userName,String passWord) {
        if(!this.userName.equals(userName)) {
            throw new userNameException("用户名错误");
        }
        if(!this.passWord.equals(passWord)) {
           throw new passWordException("密码错误");
        }
        System.out.println("登录成功");
    }
}
public class Test {
    public static void main(String[] args) {
        Login login = new Login();
        login.setUserName("123");
        login.setPassWord("123");
        try {
            login.loginInfo("321","123");
        }catch (userNameException e) {
            e.printStackTrace();
        }catch (passWordException e) {
            e.printStackTrace();
        }
    }
}